Skip to content

fixes evaluation order of stack trace #8568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

homberghp
Copy link
Contributor

@homberghp homberghp commented Jun 7, 2025

This version works for ant projects. (Including netbeans projects).
This PR closes #8567

This implementation of finding file object+line number reverses the search by starting at the top of the stack and try to find the stack frame that is directly related to the test method.

It reverses the loop running from bottom to top into running from the top stack frame to the bottom one.
It effectively tries to find the first stack element that matches the testMethod involved instead of the first element that is NOT in some (testing) framework. For most tests this appears to be the logical choice, in particular in the non-optimal practice of having multiple assert or assert-like statements in one test method.

For NetBeans developers, in particular those working on refactoring related stuff and tests, it is more useful to point to the failing assert or verifyXXX call than in some method inside some method inside the test class or a superclass thereof that generalizes repetitive work in the tests.

In the original the goto source landed me in

@Override
protected void runTest() throws Throwable {
//the tests are unfortunatelly not 100% stable, try to recover by retrying:
Throwable exc = null;
for (int i = 0; i < RETRIES; i++) {
try {
super.runTest();
return;
} catch (Throwable t) {
if (exc == null) exc = t;
}
}
throw exc;
}

instead of say line 118 below, which is the more logical line to choose in most cases.

This PR solves the problem for both maven and ant projects in a similar way.

@homberghp homberghp changed the title solves issue8567 by reversing order of stack evaluation closes 8567, evaluation order of stack trace Jun 13, 2025
@homberghp homberghp changed the title closes 8567, evaluation order of stack trace fixes evaluation order of stack trace Jun 13, 2025
@homberghp
Copy link
Contributor Author

solves #8567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

junit failed test jumps to wrong test line
1 participant